 <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
  //第一题
  setTimeout(() => {
    console.log("setTimeout1");
    Promise.resolve().then(data => {
      console.log(222);
    });
  });
  setTimeout(() => {
    console.log("setTimeout2");
  });
  Promise.resolve().then(data => {
    console.log(111);
  });
  /*运行结果
    111
    setTimeout1
    222
    setTimeout2
   */

  //第二题
    async function async1 () {
      console.log('async1 start')   //2
      await async2()
      console.log('async1 end')     //6
    }
    async function async2 () {
      console.log('async2')        //3
    }
    console.log('script start')    //1

    setTimeout(function () {
      console.log('setTimeout')    //8
    }, 0)

    async1()

    new Promise (function (resolve) {
      console.log('promise1')      //4
      resolve()
    }).then(function() {
      console.log('promise2')     //7
    })
    console.log('script end')     //5
</script>
</body>
</html>
